//不能为空
export const cannotBeEmpty = (message: string) => {
     return { required: true, message: message, trigger: 'change' }
}
//限制长度
export const limitLength = (number: number) => {
     return {
          max: number,
          message: `输入的文字不能超过${number}个`,
          trigger: 'change',
     }
}
//限制长度区间
export const limitLengthInterval = (min: number, max: number) => {
     return {
          pattern: new RegExp(`^.{${min},${max}}$`),
          message: `密码长度需要大于${min}小于${max}`,
          trigger: 'change',
     }
}
//限制数字
export const limitNumber = {
     pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/,
     message: '只能输入数字',
     trigger: 'change',
}

//限制密码格式
export const limitPasswordFormat = {
     pattern: /^(?![A-Za-z]+$)(?![A-Z\d]+$)(?![A-Z\W]+$)(?![a-z\d]+$)(?![a-z\W]+$)(?![\d\W]+$)/,
     message: '密码格式需要包含字母数字以及特殊字符三种格式',
     trigger: 'change',
}
//限制连续出现的特殊字符
export const limitContinuousSymbol = (number: number) => {
     return {
          pattern: new RegExp('^(?!.*?(\\W)\\1{' + (number - 1) + '}).*$'),
          message: `不能连续出现${number}次相同的特殊字符`,
          trigger: 'change',
     }
}
//限制连续出现的字母或数字
export const limitContinuousLettersOrNumbers = (number: number) => {
     return {
          pattern: new RegExp('^(?!.*?(\\w)\\1{' + (number - 1) + '}).*$'),
          message: `不能连续出现${number}次相同的字母或数字`,
          trigger: 'change',
     }
}

//限制符号
export const limitSymbol = {
     pattern: /^[A-Za-z0-9\u4e00-\u9fa5]+$/,
     message: '不允许输入空格等特殊符号',
     trigger: 'change',
}

// 电话号码
export const cellphone = {
     pattern: /^1((34[0-8])|(8\d{2})|(([35][0-35-9]|4[579]|66|7[35678]|9[1389])\d{1}))\d{7}$/,
     message: '手机号输入不正确',
     trigger: 'change',
}

// IP地址
export const IPdizhi = {
     pattern: /^((2((5[0-5])|([0-4]\d)))|([0-1]?\d{1,2}))(\.((2((5[0-5])|([0-4]\d)))|([0-1]?\d{1,2}))){3}$/,
     message: '请输入正确的Ip地址',
     trigger: 'change',
}
